package com.cwvs.cat.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cwvs.cat.R;
import com.cwvs.cat.bean.Area;
import com.cwvs.cat.bean.School;

public class SchoolsAdapter extends BaseAdapter {

	private List<School> list_contact;
	private LayoutInflater inflater;

	public SchoolsAdapter() {
		// TODO Auto-generated constructor stub
	}

	public SchoolsAdapter(Context ac, List<School> list) {
		// TODO Auto-generated constructor stub
		this.inflater = LayoutInflater.from(ac);
		this.list_contact = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list_contact.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list_contact.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewholder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.area_item, null);
			viewholder = new ViewHolder();
			viewholder.name = (TextView) convertView.findViewById(R.id.name);
			convertView.setTag(viewholder);

		} else {
			viewholder = (ViewHolder) convertView.getTag();
		}
		viewholder.name.setText(list_contact.get(position).name);
		
		return convertView;
	}

	class ViewHolder {
		TextView name;

	}
}
